feat(tools): add ReadMediaFile tool for image/video files#661
Conversation
Signed-off-by: Richard Chien <stdrc@outlook.com>
Signed-off-by: Richard Chien <stdrc@outlook.com>
Signed-off-by: Richard Chien <stdrc@outlook.com>
There was a problem hiding this comment.
Pull request overview
This PR adds a dedicated ReadMediaFile tool for reading image and video files, separating media file handling from the ReadFile tool which now focuses exclusively on text files.
Changes:
- Added new
ReadMediaFiletool with 100MB max file size, capability-based availability, and image dimension detection - Updated
ReadFileto reject image/video files and redirect users to use appropriate tools - Added comprehensive test coverage and updated documentation in both English and Chinese
Reviewed changes
Copilot reviewed 25 out of 25 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
src/kimi_cli/tools/file/read_media.py |
New tool implementation for reading image/video files with capability checks and Kimi-specific video upload support |
src/kimi_cli/tools/file/read_media.md |
Tool description template with dynamic capability-based instructions |
src/kimi_cli/tools/file/read.py |
Removed media handling code, now returns errors for image/video files |
src/kimi_cli/tools/file/read.md |
Updated description to clarify text-only focus |
src/kimi_cli/tools/file/__init__.py |
Added ReadMediaFile to exports |
src/kimi_cli/tools/__init__.py |
Added ReadMediaFile to key argument extraction |
src/kimi_cli/agents/default/agent.yaml |
Added ReadMediaFile to default agent tools |
src/kimi_cli/agents/okabe/agent.yaml |
Added ReadMediaFile to okabe agent tools |
tests/test_read_media_file.py |
Comprehensive tests for the new tool |
tests/test_read_media_file_desc.py |
Tests for capability-based descriptions |
tests/test_read_file.py |
Updated tests to expect errors for media files |
tests/test_read_file_desc.py |
Removed (old capability-based description tests) |
tests/conftest.py |
Added fixture for ReadMediaFile tool |
tests/test_tool_schemas.py |
Added schema test for ReadMediaFile |
tests/test_tool_descriptions.py |
Updated descriptions for both tools |
tests/test_default_agent.py |
Updated default agent test with ReadMediaFile |
tests/test_agent_spec.py |
Added ReadMediaFile to agent specifications |
tests/test_pyinstaller_utils.py |
Added ReadMediaFile to PyInstaller configuration |
docs/zh/customization/agents.md |
Updated Chinese documentation with ReadMediaFile |
docs/en/customization/agents.md |
Updated English documentation with ReadMediaFile |
docs/zh/release-notes/changelog.md |
Added changelog entry in Chinese |
docs/en/release-notes/changelog.md |
Added changelog entry in English |
CHANGELOG.md |
Added changelog entry |
src/kimi_cli/acp/AGENTS.md |
Added note about ReadMediaFile ACP integration |
klips/klip-12-wire-initialize-external-tools.md |
Updated KLIP status to Implemented |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| assert part.image_url.url.startswith("data:image/png;base64,") | ||
| assert result.is_error | ||
| assert result.message == snapshot( | ||
| f"`{image_file}` is a image file. Use other appropriate tools to read image or video files." |
There was a problem hiding this comment.
Grammar error: "is a image" should be "is an image" because "image" starts with a vowel sound.
| assert part.image_url.url.startswith("data:image/png;base64,") | ||
| assert result.is_error | ||
| assert result.message == snapshot( | ||
| f"`{image_file}` is a image file. Use other appropriate tools to read image or video files." |
There was a problem hiding this comment.
Grammar error: "is a image" should be "is an image" because "image" starts with a vowel sound.
| return ToolError( | ||
| message=( | ||
| f"`{path}` is {size} bytes, which exceeds the max " | ||
| f"{MAX_MEDIA_MEGABYTES}MB bytes for media files." |
There was a problem hiding this comment.
Inconsistent error message format. The error message says "{MAX_MEDIA_MEGABYTES}MB bytes" which is redundant. It should be either "{MAX_MEDIA_MEGABYTES}MB" or "{MAX_MEDIA_MEGABYTES << 20} bytes" to match the style in the comparison.
| f"{MAX_MEDIA_MEGABYTES}MB bytes for media files." | |
| f"{MAX_MEDIA_MEGABYTES << 20} bytes for media files." |
|
|
||
| from kaos.path import KaosPath | ||
| from kosong.chat_provider.kimi import Kimi | ||
| from kosong.tooling import CallableTool2, ToolError, ToolOk, ToolReturnValue |
There was a problem hiding this comment.
Import of 'CallableTool2' is not used.
Summary
Add a dedicated
ReadMediaFiletool for reading image and video files, separating media file handling from theReadFiletool which now focuses exclusively on text files.Changes
New Tool:
ReadMediaFileimage_in/video_incapabilities)Updated Tool:
ReadFileReadMediaFileOther Changes
ReadMediaFileto default and okabe agent configurations